package edu.lfsfxy.myschool.controller;

import edu.lfsfxy.myschool.dao.StudentDao;
import edu.lfsfxy.myschool.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentDao studentDao;
    @RequestMapping("/add")
    public String studentAdd(Student student){
        studentDao.add(student);
        return "success";
    }
    @RequestMapping("/findAll")
    public String studentFindAll(Model model){
        List<Student> list = studentDao.findAll();
        model.addAttribute("list",list);
        return "studentList";
    }
}
